<?php

/**
 * This is the model class for table "{{problem_teachernum}}".
 *
 * The followings are the available columns in table '{{problem_teachernum}}':
 * @property double $exam_id
 * @property double $school_id
 * @property double $subject_id
 * @property string $problem_id
 * @property double $user_id
 * @property double $is_group
 * @property double $num_id
 */
class ProblemTeachernum extends CActiveRecord
{
	/**
	 * Returns the static model of the specified AR class.
	 * @param string $className active record class name.
	 * @return ProblemTeachernum the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}

	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return '{{problem_teachernum}}';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('exam_id, school_id, subject_id, user_id, is_group', 'numerical'),
			array('problem_id', 'length', 'max'=>255),
			// The following rule is used by search().
			// Please remove those attributes that should not be searched.
			array('exam_id, school_id, subject_id, problem_id, user_id, is_group, num_id', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'exam_id' => 'Exam',
			'school_id' => 'School',
			'subject_id' => 'Subject',
			'problem_id' => 'Problem',
			'user_id' => 'User',
			'is_group' => 'Is Group',
			'num_id' => 'Num',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
	 */
	public function search()
	{
		// Warning: Please modify the following code to remove attributes that
		// should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('exam_id',$this->exam_id);
		$criteria->compare('school_id',$this->school_id);
		$criteria->compare('subject_id',$this->subject_id);
		$criteria->compare('problem_id',$this->problem_id,true);
		$criteria->compare('user_id',$this->user_id);
		$criteria->compare('is_group',$this->is_group);
		$criteria->compare('num_id',$this->num_id);

		return new CActiveDataProvider($this, array(
			'criteria'=>$criteria,
		));
	}
}